package com.java.repository;

import com.java.entity.UserAccount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

public interface UserAccountRespository extends JpaRepository<UserAccount, Long> {
    @Transactional(rollbackFor = Exception.class)
    @Modifying(clearAutomatically = true)
    @Query(value = "update user_account set amount=?2 where account_id =?1 ", nativeQuery = true)
    void updateAmount(Long accountId, BigDecimal amount);
}
